<?

function upLoadPic($name,$id)
{   
   
	$cl = trim($name['name']);
	$pic="";
	$fileName="";
	if(isset($cl) and $cl != "")
	{   
		$temp_fileName = explode(".", $name['name']);
		if(!file_exists("admin/webimage/"))
		@mkdir("../admin/webimage/", 0777);
		$uploadDir = "../admin/webimage/";
		$fileName = "image".$id.".".$temp_fileName[1];
		$uploadFile = $uploadDir.$fileName;
		if( move_uploaded_file($name['tmp_name'], $uploadFile) )
			{
				return $fileName;
			}else{
				return "error";
			}
	}
}
function upLoadPic1($name,$id)
{
	$cl = trim($name['name']);
	$pic="";
	$fileName="";
	if(isset($cl) and $cl != "")
	{
		$temp_fileName = explode(".", $name['name']);
		if(!file_exists("upload_images/"))
		mkdir("upload_images/", 0777);
		$uploadDir = "upload_images/";
		$uploadFile = $uploadDir.$id;
		if( move_uploaded_file($name['tmp_name'], $uploadFile) )
		{
			return $fileName;
		}else{
			return "error";
		}
	}
}
function upLoadPic2($name,$id)
{
	$cl = trim($name['name']);
	$pic="";
	$fileName="";
	if(isset($cl) and $cl != "")
	{
		$temp_fileName = explode(".", $name['name']);
		if(!file_exists("../upload_images/"))
		mkdir("../upload_images/", 0777);
		$uploadDir = "../upload_images/";
		$uploadFile = $uploadDir.$id;
		if( move_uploaded_file($name['tmp_name'], $uploadFile) )
		{
			return $fileName;
		}else{
			return "error";
		}
	}
}
//*******For the Image *************
function make_tumb_nail($img_name,$height,$width)
{ 
	$size=@getimagesize("$img_name");
	 $wd=$size[0]; 
    $ht=$size[1]; 
	
		if($ht > $wd)
		{ 
			$h = $ht; 
				for($i = 1.01; ; )
				{ 
					if($h < $height)
					{ 
						break; 
					} 
					
					$h = $ht/$i; 
					$w = $wd/$i; 
					$i = $i + 0.01; 
				} 
		} 
		else 
		{ 
			$w = $wd; 
				for($i=1.01;;)
				{ 
					if($w < $width)
					{ 
						break; 
					} 
				
				$h=$ht/$i; 
				$w=$wd/$i; 
				$i=$i+0.01; 
				} 
		} 
		if(!isset($w))
			$w=$wd;
		if(!isset($h))
			$h=$ht;
		
		$wd=floor(round($w)); 
		$ht=floor(round($h)); 
		$returnstring="width=$wd height=$ht border=0"; 
		return $returnstring; 
}//end function 
function emailFormat($to , $from , $subject , $emailMessage)
{
	$htmlFormat = '<style type="text/css">
				.text {font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
				.heading_bold_black
				{
					font-family: Arial, "MS Sans Serif";
					font-size: 14px;
					color: #000000;
					font-weight: bold;
				}
				.brd {
					BORDER-RIGHT: #000000 1px solid; 
					BORDER-TOP: #000000 1px solid; 
					BORDER-LEFT: #000000 1px solid; 
					BORDER-BOTTOM: #000000 1px solid; 
					border-color: #3399CC;
				}
				.style1 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }
			</style>
				<table width="800" align="center" cellpadding="0" cellspacing="0"  >						
					<tr>
						<td  valign="top">'.$emailMessage.'</td>
					</tr> 									
				</table>'; 
	
	// Always set content-type when sending HTML email
	$headers = "MIME-Version: 1.0" . "\r\n";
	$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";// More headers
	$headers .= "From: ".$from . "\r\n";
	
	if(@mail($to , $subject , $emailMessage , $headers))
	return true;
}


  function generatePassword ($length = 8)
  {

    // start with a blank password
    $password = "";

    // define possible characters - any character in this string can be
    // picked for use in the password, so if you want to put vowels back in
    // or add special characters such as exclamation marks, this is where
    // you should do it
    $possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ";

    // we refer to the length of $possible a few times, so let's grab it now
    $maxlength = strlen($possible);
  
    // check for length overflow and truncate if necessary
    if ($length > $maxlength) {
      $length = $maxlength;
    }
	
    // set up a counter for how many characters are in the password so far
    $i = 0; 
    
    // add random characters to $password until $length is reached
    while ($i < $length) { 

      // pick a random character from the possible ones
      $char = substr($possible, mt_rand(0, $maxlength-1), 1);
        
      // have we already used this character in $password?
      if (!strstr($password, $char)) { 
        // no, so it's OK to add it onto the end of whatever we've already got...
        $password .= $char;
        // ... and increase the counter by one
        $i++;
      }

    }

    // done!
    return $password;

  }
?>